layui.use(['form','layedit','laydate','element','table','jquery'],function(){
	var form = layui.form,
	layer = layui.layer,
	layedit = layui.layedit,
	element = layui.element,
	$ = layui.$,
	table = layui.table;

	table.render({
		elem: '#menu_table',
		url:'menu/getList',
		height: 'auto',
		page: true,
		limits: [10,20,50],
		limit: 10,
		skin: 'row',//边框风格：行
		even: true,//开启隔行背景
		id: 'menuTable',
		cols:[[
			{
				checkbox: true
			},{
				field: 'name',
				title: '名称',
				width: 200
			},{
				field: 'url',
				title: 'url',
				width: 200
			},{
				field: 'enable',
				title: '是否可用',
				width: 200,
				templet: '#enable'
			},{
				title: '操作',
				width: 200,
				templet: '#bar'
			}
			]]
	});
	table.on('tool(table_list)',function(obj){
		var data = obj.data;
		console.info(data);
		if(obj.event === 'edit'){
			layer.msg("编辑");
		}else if(obj.event === 'del'){
			layer.msg("删除");
		}
	});
	
	$("#test").click(function(){
		var index = layer.open({
			type: 1,
			title: "用户列表",
			shade:0.5,
			id: 'test_dialog',
			moveType: 1,
			content: `<table id="user_table" lay-filter="table_list"></table>`,
			success: function(layero){
				console.info($("#user_table"));
				table.render({
					elem: '#user_table',
					url:'user/list',
					height: 'auto',
					page: true,
					limits: [10,20,50],
					limit: 10,
					skin: 'row',//边框风格：行
					even: true,//开启隔行背景
					id: 'userTable',
					cols:[[
						{
							checkbox: true
						},{
							field: 'name',
							title: '名称',
							width: 200
						},{
							field: 'code',
							title: 'url',
							width: 200
						}
						]]
				});
			}
		});
	});

	$("#add").click(function(){
		var index = layer.open({
			type: 1,
			title: "添加菜单",
			area: "500px",
			shade:0.5,
			id: 'add_dialog',
			moveType: 1,
			content: `<span>我试试</span>
				`,
				btn: ['按钮一', '按钮二', '按钮三','按钮4']
			,yes: function(index, layero){
				layer.msg('按钮一', {icon: 6});
			}
			,btn2: function(index, layero){
				layer.alert('按钮二酷毙了', {icon: 1});
				return false;
			}
			,btn3: function(index, layero){
			//按钮【按钮三】的回调
				layer.alert('按钮三', function(index){
					  //do something
					 layer.close(index);
				});
				return false;
			},
			btn4: function(index, layero){
				
				}
			,cancel: function(){ 
			//右上角关闭回调
				layer.msg("关闭啊啊啊！");
			},
		success: function(layero){

		}
		});
	});
})